import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;


public class Thief {
	
	private Tile loc;
	private BufferedImage image;
	private SOCApplet applet;
	
	public Thief(SOCApplet applet){
		ArrayList<Tile> tiles = applet.tileHolder.getTiles();
		for(Tile t : tiles){
			if(t.getType() == 6){
				loc = t;
			}
		}
		this.applet = applet;
		try {
			image = ImageIO.read(new File("thief.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void drawSelf(Graphics g){
		g.drawImage(image, (loc.getX() + 1) * 49 - 15, loc.getY() * 50 + 26 * loc.getY() + 10, null);
	}
	
	public void move(Tile t){
		System.out.println("test");
		loc = t;
	}
	
	public void activate(){
		for(Player p : applet.players){
			if(p.getBrick() + p.getGrain() + p.getLumber() + p.getOre() + p.getWool() >= 10){
				applet.turn.setTargetObject('D');
				((DiscardMenu)applet.menus.getDiscardMenu()).open(p);
			}
		}
		applet.turn.promptMoveThief();
		System.out.println("Click a tile for the thief to go to.");
	}
}
